package com.my.screenadapter.MyProgress;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import android.widget.ProgressBar;

import com.my.screenadapter.R;
import com.my.screenadapter.View.CustomProgressDialog;
import com.my.screenadapter.View.ProgressDialog;
import com.my.screenadapter.utils.BitmapUtils;

/**
 * Created by 张英杰 on 2016/12/13.
 *
 * loading 最佳实践
 */
public class MyProgressActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.myprogress_activity);
//        progressStart();
        findViewById(R.id.btn1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                progressStart();
            }
        });
        findViewById(R.id.btn2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                progressStart2();
            }
        });

    }

    Handler mhandler = new Handler();

    private void progressStart() {
        final CustomProgressDialog mdialog = new CustomProgressDialog(MyProgressActivity.this, "请稍后123。。。");
        mdialog.show();
        mhandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (mdialog.isShowing()) {
                    mdialog.dismiss();
                }
            }
        }, 3000);
    }

    private void progressStart2() {
        final ProgressDialog mdialog = ProgressDialog.createDialog(MyProgressActivity.this);

        mdialog.show();
        mhandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (mdialog.isShowing()) {
                    mdialog.dismiss();
                }
            }
        }, 3000);
    }

}
